import MyMath from "./math.js";
runOnStartup(async runtime => {
    runtime.addEventListener("tick", () => tick())
    runtime.getLayout("MainLevel").addEventListener("afterlayoutstart", () => init())
});
function tick() {
    if (runtime.layout.name != "MainLevel") return;
}
function init() {
    gemSpwn.init()
    gemSpwn.spwn()
}
globalThis.gemSpwn = {
    init: function () {
        /** @type {ISpriteInstance} */
        this.SpwnPointMask = runtime.objects.gemSpwnPoint.getFirstInstance()
        this.spwnTime = MyMath.randomNum(1000,6000)
    },
    spwn: function () {
        /**@type {ISpriteInstance} */
        let gemSpwmPoint = this.SpwnPointMask
        setInterval(() => {
            let ramPoint = MyMath.randomNum(0, 16)
            let spwnx = gemSpwmPoint.getImagePointX(ramPoint)
            let spwny = gemSpwmPoint.getImagePointY(ramPoint)
            /** @type {I3DShapeInstance} */
            let newGem = runtime.objects.Gem.createInstance("gem", spwnx, spwny, true)
            newGem.width *= 1.5
            newGem.height *= 1.5
            newGem.zHeight *= 1.5
            this.spwnTime = MyMath.randomNum(1000 ,6000)
        }, this.spwnTime)
    }
}
export default gemSpwn